package config

import (
	"encoding/json"
	"os"
)

type ModelConfig struct {
	Playlist []string `json:"playlist"`
	Bilibili struct {
		Roomid          string   `json:"roomid"`
		BarrageInterval int      `json:"barrageInterval"`
		AdminUids       []string `json:"adminUids"`
		CmdPrefix       string   `json:"cmdPrefix"`
	} `json:"bilibili"`
	HealthInterval int    `json:"healthInterval"`
	PushCmdSetting string `json:"pushCmdSetting"`
}

var Config = &ModelConfig{}

func init() {
	getenv := os.Getenv("env")
	if getenv == "" {
		getenv = "local"
	}
	bytes, err := os.ReadFile(`./config/config.` + getenv + ".json")
	if err != nil {
		panic(err)
	}
	err = json.Unmarshal(bytes, Config)
	if err != nil {
		panic("配置文件错误：" + err.Error())
	}
}
